/* ExamController.java
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 * 
 */

package controllers;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import domain.Exam;

import services.ExamService;

@Controller
@Transactional
@RequestMapping("/exam")
public class ExamController extends AbstractController {
	
	// Services ---------------------------------------------------------------
	@Autowired
	ExamService examService;
	// TODO: Add autowired services.

	// Constructors -----------------------------------------------------------
	
	public ExamController() {
		super();
	}
	
	// Listing ----------------------------------------------------------------

	@RequestMapping(value = "/findByCertificationId")
	public ModelAndView findByCertificationId(@RequestParam int certificationId) {
		ModelAndView result;

		// TODO: Complete this method.
		Collection<Exam> exams;
		
		exams = examService.getExams(certificationId);
		result = new ModelAndView("exam/dropdown");
		result.addObject("exams", exams);

		return result;
	}

}